package com.itlong.cloud.operate;

import com.itlong.cloud.equip.operate.IOperateDeviceManageServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <desc>
 * 定时获取设备日志
 * </desc>
 *
 * @create 2021/4/27
 */
//@EnableScheduling
//@RestController
public class OperateGetDeviceLogTask {
    private static Logger LOG = LoggerFactory.getLogger(OperateGetDeviceLogTask.class);
    @Autowired
    private IOperateDeviceManageServiceClient iOperateDeviceManageServiceClient;

    /**
     * <desc>
     * 开始从设备端主动获取日志
     * </desc>
     *
     * @author maju
     * @createDate 2021/4/27
     */
//    @Scheduled(cron = "0 0 0 * * ? ")
    public void timeTaskGetDeviceLog() {
        try {
            LOG.info("开始从设备端主动获取日志");
            iOperateDeviceManageServiceClient.getDeviceLogByTask();
        } catch (Exception e) {
            throw new DataAccessException("【开始从设备端主动获取日志】开始从设备端主动获取日志失败", e);
        }
    }


    /**
     * <desc>
     * 下载日志
     * </desc>
     *
     * @author maju
     * @createDate 2021/4/27
     */
//    @Scheduled(cron = "0 0 1-5 * * ? ")
    public void timeTaskDownloadDeviceLog() {
        try {
            LOG.info("开始从设备端主动下载日志");
            iOperateDeviceManageServiceClient.downloadDeviceLogByTask();
        } catch (Exception e) {
            throw new DataAccessException("【开始从设备端主动下载日志】开始从设备端主动下载日志失败", e);
        }
    }
}
